﻿using System.Linq;
using System.Xml.Serialization;
using ElectronicCommerce.Framework.Configuration.Attributes;

namespace ElectronicCommerce.Framework.Web.Configuration.Resource
{
    [ConfigFile("~/Configuration/Site/Javascript.config", ConfigPathType.ServerPath)]
    [XmlRoot("javascripts", Namespace = WebConfigurationNamespaces.NAMESPACE_SITE)]
    public class JavascriptConfiguration
    {
        [XmlElement("javascript")]
        public JavascriptCollection Javascripts { get; set; }

        public Javascript GetJavascript(string name)
        {
            return Javascripts.Where(j => j.Name.ToLower() == name.ToLower()).SingleOrDefault();
        }
    }
}
